/*!
	* @Title: 经销商管理
	* @author 		naluv125@hotmail.com
	* @date 			2013-7-27 下午12:59:34   
	* @version    	V1.0
 */

Ext.define('MyDesktop.Tdist', {
    extend: 'Ext.ux.desktop.Module',

    requires: [
        'Bleext.abstract.GridForm'
    ],

    id:'tdist-win',

    init : function(){
        this.launcher = {
            text: '经销商管理',
            iconCls:'img_dist'
        };
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('tdist-win');
        if(!win){
        	var dist = this.buildDistModule();
            win = desktop.createWindow({
                id: 'tdist-win',
                title:'经销商管理',
                width:990,
                height:610,
                iconCls: 'img_dist',
                animCollapse:false,
                border:false,
                constrainHeader:true, //窗口顶部不能超过浏览器外界

                layout: 'fit',
                items: [dist]
            });
        }
        return win;
    },
    
    buildDistModule:function(){
    		var distInst = Ext.create('Bleext.abstract.GridForm',{
    			pageLoad:true,
    			formColumnCount:3,
    			gridTitle : '查询结果',
    			formTitle: '经销商查询',
    		    loadGridUrl:BP+'dist/pageQueryTdist',
    		    addUrl:BP+'dist/insertTdist',
    			updateUrl:BP+'dist/updateTdist',
    			removeUrl:BP+'dist/removeTdist',
    		    
    			columnConfig: [ {header: 'ID', dataIndex: 'id', hideGrid: true, hideForm: 'add', hidden:true ,readOnly: true},
			    				            {header: '经销商编号', dataIndex: 'distributorCode', allowBlank:false,vtype:'distcode',sortable:true,uneditable:true,width:140},
			    				            {header: '上级编号', dataIndex: 'sponsorCode', allowBlank:false,width:140},  //输入上级编号的时候需要去数据库验证，数据库无记录的情况新增可以为空
			    				            {header: '经销商名称', dataIndex: 'distributorName', allowBlank:false ,width:140},
			    				            {header: '职级',  dataIndex: 'rankId', hidden:true ,hideGrid:true,sortable:true,width:100},
			    				            {header: '职级',  dataIndex: 'rankId_Name', hideForm:'all',sortable:true,remoteSort:true,width:100},
			    				            {header: '上级ID', dataIndex: 'sponsorId',hideGrid:true ,hidden:true},
			    				            {header: '上级名称', dataIndex: 'sponsor_Name', hideForm:'all',width:140},
			    				            {header: '所在店铺', dataIndex: 'shopId', allowBlank:false ,fieldtype:'shopListcombo',hideGrid:true ,hiddenName:'shopId',width:160},
			    				            {header: '所在店铺', dataIndex: 'shop_Code', hideForm:'all',sortable:true},
			    				            {header: '联系地址', dataIndex: 'address',width:200},
			    				            {header: '联系电话', dataIndex: 'telephone',width:140,vtype:'phone'},
			    				            {header: '加入时间',dataIndex: 'createTime',hideForm:'all',width:172,remoteSort:true,sortable:true,width:140},
			    				            {header: '银行账号', dataIndex: 'bankAcc',width:200 , vtype:'bank'}],
    			                 			 
    			formConfig:[{xtype:'rankCombo', fieldLabel: '职级', name: 'rankId', hiddenName:'rankId' , anchor:'100%'},
		    			              {xtype:'textfield', fieldLabel: '经销商编号', name: 'distributorCode', anchor:'100%'},
		    			              {xtype:'textfield', fieldLabel: '经销商名称', name: 'distributorName', anchor:'100%'} ]
    		});
    		return distInst;
    }
});
